#include <iostream>
#include <unistd.h>
#include <signal.h>

using namespace std;

void handler(int s)
{
    cout << "信号：" << s << endl;
}
int main()
{
    signal(2, SIG_IGN);

    struct sigaction act, oact;
    act.sa_flags = 0;
    sigemptyset(&act.sa_mask);
    act.sa_handler = handler;

    cout << "pid：" << getpid() << endl;

    // 设置进当前调用进程的PCB中
    sigaction(2, &act, &oact);
    cout << "default action：" << (int)oact.sa_handler << endl;
    while (true)
    {
        sleep(1);
    }
    return 0;
}